#!/bin/bash

nhosts=$1
file=hosts

/services/verif_ativos.sh > $file

cat $file | sed s/'64 bytes from '// | sed s/.cluster.*// > /tmp/$$

nlines=`wc -l < /tmp/$$`
headcut=`expr $nlines - 3`
tailcut=`expr $headcut - 1`

cat /tmp/$$ | head -n $headcut | tail -n $tailcut > $file

if [ ! -z $nhosts ]; then
	cat $file | head -n $nhosts > /tmp/$$
	cp /tmp/$$ $file
fi

cat $file | wc -l
